home *** CD-ROM | disk | FTP | other *** search
- { ustr.pas -- String routines for StrDLL }
-
- unit UStr;
-
- interface
-
- uses Wintypes, WinProcs, Strings;
-
- function StrNCopy(Source: String; var P: PChar): PChar; export;
- function StrTok(var Next: PChar; P: PChar; C: Char): PChar; export;
- procedure StrFill(P: PChar; C: Char; Size: Word); export;
-
- implementation
-
- {- Copy Source string to heap. Return addr in P & fn result }
- function StrNCopy(Source: String; var P: PChar): PChar;
- begin
- GetMem(P, Length(Source) + 1);
- if P <> nil then StrPCopy(P, Source);
- StrNCopy := P
- end;
-
- {- Return pointer to next token in P or previous P if P = nil }
- { Set Next to nil on first call; P to nil on subsequent calls }
- function StrTok(var Next: PChar; P: PChar; C: Char): PChar;
- begin
- if P = nil then P := Next;
- Next := StrScan(P, C);
- if Next <> nil then
- begin
- Next^ := #0;
- Next := @Next[1]
- end;
- StrTok := P
- end;
-
- { Fill string at P with chars C. Size = size of P^ in bytes }
- procedure StrFill(P: PChar; C: Char; Size: Word);
- begin
- if (P <> nil) and (Size > 0) then
- begin
- Dec(Size);
- if Size > 0 then
- FillChar(P^, Size, C);
- P[Size] := #0
- end
- end;
-
- end.
-
-
- {--------------------------------------------------------------
- Copyright (c) 1991 by Tom Swan. All rights reserved.
- Revision 1.00 Date: 5/25/1991
- ---------------------------------------------------------------}
-